module("Flag", package.seeall )

usermessage.Hook("SFFlag", function( um )
	
	local Id = um:ReadChar()
	
	if Id == 0 then
		
		local ply = um:ReadEntity()
		local flag = um:ReadEntity()
		
		hook.Call("FlagCaptured", GAMEMODE, ply, flag )
		
		GameSound.PlayTeam( ply:Team(), GameSound.SCORE )
		
	elseif Id == 1 then
	
		local ply = um:ReadEntity()
		local flag = um:ReadEntity()
	
		hook.Call("FlagReset", GAMEMODE, ply, flag )
		
		GameSound.PlayTeam( flag:Team(), GameSound.RETURN )
		
	elseif Id == 2 then
	
		local ply = um:ReadEntity()
		local flag = um:ReadEntity()
	
		hook.Call("FlagPicked", GAMEMODE, ply, flag )
		
		GameSound.PlayTeam( ply:Team(), GameSound.HAS )
		
	elseif Id == 3 then
	
		local ply = um:ReadEntity()
		local flag = um:ReadEntity()
	
		hook.Call("FlagDrop", GAMEMODE, ply, flag )
		
		GameSound.PlayTeam( ply:Team(), GameSound.DROP )
	
	end

end )